package com.aabte.design2.behavioral.state;

import lombok.Data;

import java.util.List;

/**
 * 音频播放器（Audio­Player）类即为上下文。它还会维护指向状态类实例的引用，
 * 该状态类则用于表示音频播放器当前的状态。
 *
 * @author Daniel
 * @version 1.0
 * @date 2020/5/4
 */
@Data
public class AudioPlayer {

    private State state;
    private int volume;
    private List<String> playList;
    private String currentSong;

    private boolean playing;

    public AudioPlayer() {
        this.state = new ReadyState(this);
    }

    public void startPlayback() {
        System.out.println("开始播放");
        this.playing = true;
    }

    public void stopPlayback() {
        System.out.println("停止播放");
        this.playing = false;
    }

    public void nextSong() {
        System.out.println("播放下一曲");
        this.playing = true;
    }

    public void previousSong() {
        System.out.println("播放上一曲");
        this.playing = true;
    }


    public void changeState(State state) {
        this.state = state;
    }

    public void clickLock() {
        state.clickLock();
    }

    public void clickPlay() {
        state.clickPlay();
    }

    public void clickNext() {
        state.clickNext();
    }

    public void clickPrevious() {
        state.clickPrevious();
    }

}
